package com.hnevc.androiddemo0625.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hnevc.androiddemo0625.R;

public class StudentInfoAdapter extends BaseAdapter {
    Context context;
    String[] names;
    String[] studentid;

    public StudentInfoAdapter(Context context, String[] names, String[] studentid) {
        this.context = context;
        this.names = names;
        this.studentid = studentid;
    }

    @Override
    public int getCount() {
        return names.length;
    }

    @Override
    public Object getItem(int position) {
        return names[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = View.inflate(context, R.layout.student_item_info,null);

        }
        TextView name = convertView.findViewById(R.id.username_tv);
        TextView studentidTv = convertView.findViewById(R.id.studentid_tv);
        name.setText(names[position]);
        studentidTv.setText(studentid[position]);
        return convertView;
    }
}
